package artid.com.arttogo.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;

import java.util.List;

import artid.com.arttogo.R;
import artid.com.arttogo.bean.CommentList;
import artid.com.arttogo.network.BitmapCache;
import artid.com.arttogo.task.CallbackSky;

public class AtMeAdapter extends BaseAdapter {
	private Context mContext;
	LayoutInflater mInflater;
	ViewHolder holder;
	CallbackSky cs;
	public List<CommentList> list;
	private ImageLoader mImageLoader;
	public AtMeAdapter(Context mContext, List<CommentList> list) {
		this.mContext = mContext;
		mInflater = LayoutInflater.from(mContext);
		this.list = list;
			
	RequestQueue mQueue = Volley.newRequestQueue(mContext);
	mImageLoader = new ImageLoader(mQueue, new BitmapCache());
	
	
	
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return 0;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	public void addList(List<CommentList> list) {
		this.list.addAll(list);
		notifyDataSetChanged();
	}
	
	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder vh = null;
		System.out.println();
		if (convertView == null) {
			vh = new ViewHolder();
			convertView = mInflater.inflate(R.layout.item_at_me, null);
			 vh.text = (TextView) convertView
			 .findViewById(R.id.atme_item_title);
			 vh.state = (TextView) convertView
					 .findViewById(R.id.atme_item_state);
			convertView.setTag(vh);
		} else {
			vh = (ViewHolder) convertView.getTag();
		}
		CommentList itemCommentList = list.get(position);
		vh.text.setText(itemCommentList.getTitle());
		if(itemCommentList.getRead().equals("0")){
			vh.state.setText("已读");
		}
		else {
			vh.state.setText("未读");
			vh.state.setTextColor(Color.RED);
		}
		
		return convertView;
	}

	class ViewHolder {
		TextView text,state;
		

	}
}
